<template>
    <div>
        <el-drawer title="" :visible.sync="drawer" :direction="direction" :before-close="handleClose" custom-class="drawer-info">
            <div class="info-item">
                <h5 class="from-title">基本信息</h5>
                <div class="form-item">
                    <label class="form-item-label">会员id:</label>
                    <div class="form-item-content">{{ objInfo.memberIdName }}</div>
                </div>
                <div class="form-item">
                    <label class="form-item-label">会员余额账户id:</label>
                    <div class="form-item-content">{{ objInfo.memberAccountId }}
                    </div>
                </div>
                <div class="form-item">
                    <label class="form-item-label">金额:</label>
                    <div class="form-item-content">{{ objInfo.money }}
                    </div>
                </div>
                <div class="form-item">
                    <label class="form-item-label">流水类型（加或减）:</label>
                    <div class="form-item-content">{{ objInfo.typeName }}</div>
                </div>
                <div class="form-item">
                    <label class="form-item-label">类别（为什么加或减）:</label>
                    <div class="form-item-content">{{ objInfo.categoryName }}</div>
                </div>
            </div>
        </el-drawer>
    </div>
</template>
<script>
    import { memberaccountserialInfo } from "@/api/member/memberaccountserial.js";
    import { enumList,urlList, } from "@/api/public.api.js";
    export default {
        data() {
            return {
                drawer: true,
                direction: "rtl",
                objInfo: {},
                PointsTypeList:[],
                PointsCategoryList:[],
                memberIdList:[],
            }
        },
        created() {
        },
        methods: {
          queryEnumList(){
              this.PointsTypeList = [];
              enumList("PointsType","").then((resp) => {
                if (resp.code == 0) {
                  this.PointsTypeList = resp.data;
                }
              });
              this.PointsCategoryList = [];
              enumList("PointsCategory","").then((resp) => {
                if (resp.code == 0) {
                  this.PointsCategoryList = resp.data;
                }
              });
          },
          queryUrlList(){
              this.memberIdList = [];
              urlList("/member/member/list").then((resp) => {
                if (resp.code == 0) {
                  if (resp.data) {
                    resp.data.forEach((item) => {
                      this.memberIdList.push({ code: item.id, name: item.nickName });
                    });
                  }
                }
              });
          },
            init(id) {
                this.queryEnumList();
                this.queryUrlList();
                if (id) {
                   memberaccountserialInfo(id).then(res => {
                        this.objInfo = res.data
                              let memberIdObj = this.memberIdList.find((item) => {
                                return item.code == this.objInfo.memberId;
                              });
                              this.objInfo.memberIdName = memberIdObj ? memberIdObj.name : "";
                              let typeObj = this.PointsTypeList.find((item) => {
                                return item.code == this.objInfo.type;
                              });
                              this.objInfo.typeName = typeObj ? typeObj.name : "";
                              let categoryObj = this.PointsCategoryList.find((item) => {
                                return item.code == this.objInfo.category;
                              });
                              this.objInfo.categoryName = categoryObj ? categoryObj.name : "";
                   })

                }
                this.drawer = true
            },
            // 关闭抽屉
            handleClose(done) {
                done()
            },
        },
    }
</script>
<style scoped>
    .from-title {
        margin-bottom: 20px;
        padding: 0 20px 20px 20px;
        font-size: 16px;
        color: #17233d;
        border-bottom: 1px solid #eee;
    }
    .info-item {
        margin-bottom: 40px;
    }

    .form-item {
        margin-bottom: 20px;
        font-size: 14px;
    }
    .form-item-label {
        text-align: right;
        float: left;
        width: 25%;
    }
    .form-item-content {
        margin-left: 30%;
        width: 70%;
    }
</style>
